//
//  QSHomeHeaderItemCell.m
//  DigitalEconomy_iOS
//
//  Created by Ding on 2020/3/18.
//  Copyright © 2020 DingC. All rights reserved.
//

#import "QSHomeHeaderItemCell.h"
@interface QSHomeHeaderItemCell ()

@end
@implementation QSHomeHeaderItemCell
- (instancetype)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = [UIColor QSColorWhiteFFFFFF];
        [self loadUI];
        self.backgroundColor = [UIColor clearColor];
    }
    return self;
}


- (void)layoutSubviews{
    if (_isVisitCell) {
        self.imageView.layer.cornerRadius = 0;
        [self.imageView mas_updateConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.contentView);
            make.top.equalTo(self.contentView).offset(kRealValue(30));
            make.size.mas_equalTo(CGSizeMake(kRealValue(24), kRealValue(24)));
        }];
        [self.titleLabel mas_updateConstraints:^(MASConstraintMaker *make) {
            make.centerX.equalTo(self.contentView);
            make.top.equalTo(self.imageView.mas_bottom).offset(kRealValue(8));
            make.height.equalTo(@kRealValue(12));
            make.left.and.right.equalTo(self.contentView);
        }];
    }
}

//- (void)configSubView{
//    self.backgroundColor = [UIColor clearColor];
//    self.contentView.layer.cornerRadius = 8;
//    self.contentView.layer.masksToBounds = YES;
//    self.contentView.backgroundColor = [UIColor QSColorWhiteFFFFFF];
//    [self.contentView mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.leading.equalTo(self.mas_leading).offset(kRealValue(10));
//        make.trailing.equalTo(self.mas_trailing).offset(kRealValue(-10));
//        make.top.equalTo(self.mas_top).offset(kRealValue(0));
//        make.bottom.equalTo(self.mas_bottom).offset(kRealValue(0));
//    }];
//}
- (void)loadUI {
    [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView);
        make.top.equalTo(self.contentView).offset(kRealValue(17));
        make.size.mas_equalTo(CGSizeMake(kRealValue(48), kRealValue(48)));
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.contentView);
        make.top.equalTo(self.imageView.mas_bottom).offset(kRealValue(10));
        make.height.equalTo(@kRealValue(12));
        make.left.and.right.equalTo(self.contentView);
    }];
}

#pragma mark - **************** Setter Getter
- (UIImageView *)imageView {
    if (!_imageView) {
        _imageView = [[UIImageView alloc] init];
        _imageView.layer.cornerRadius = 24;
        _imageView.layer.masksToBounds = YES;
        _imageView.contentMode = UIViewContentModeScaleAspectFill;
        [self.contentView addSubview:_imageView];
    }
    return _imageView;
}

- (UILabel *)titleLabel {
    if (!_titleLabel) {
        _titleLabel = [[UILabel alloc] init];
        _titleLabel.font = [UIFont QSFontOfSize12];
        _titleLabel.textColor = [UIColor QSColorBlack434343];
        _titleLabel.textAlignment = NSTextAlignmentCenter;
        [self.contentView addSubview:_titleLabel];
    }
    return _titleLabel;
}

- (void)setItemModel:(QSItemModel *)itemModel{
    _itemModel = itemModel;
    
    self.titleLabel.text = itemModel.label;
    if ([itemModel.label isEqualToString:@"新增走访"]) {
        self.imageView.image = [UIImage imageNamed:@"home_addvisit"];
    }
    if ([itemModel.label isEqualToString:@"领导驾驶舱"]) {
        self.imageView.image = [UIImage imageNamed:@"home_leadership"];
    }
    if ([itemModel.label isEqualToString:@"一企一档"]) {
        self.imageView.image = [UIImage imageNamed:@"home_enterprise_Archives"];
    }
    if ([itemModel.label isEqualToString:@"驻企签到"]) {
        self.imageView.image = [UIImage imageNamed:@"home_signin"];
    }
    if ([itemModel.label isEqualToString:@"企业走访"]) {
        self.imageView.image = [UIImage imageNamed:@"home_visit"];
    }
    if ([itemModel.label isEqualToString:@"问题处理"]) {
        self.imageView.image = [UIImage imageNamed:@"home_problemdeal"];
    }
    if ([itemModel.label isEqualToString:@"问题上报"]) {
        self.imageView.image = [UIImage imageNamed:@"home_sendproblem"];
    }
    //新增
    if ([itemModel.label isEqualToString:@"政策宝典"]) {
        self.imageView.image = [UIImage imageNamed:@"home_policy"];
    }
    if ([itemModel.label isEqualToString:@"企业运行监测"]) {
        self.imageView.image = [UIImage imageNamed:@"ic_monitoring"];
    }
//     switch ([itemModel.key integerValue]) {
//         case 1:
//         {//领导驾驶舱
//             self.imageView.image = [UIImage imageNamed:@"home_leadership"];
//         }
//             break;
//           case 2://一企一档
//           {
//               self.imageView.image = [UIImage imageNamed:@"home_enterprise_Archives"];
//           }
//               break;
//           case 3://驻企签到
//           {
//               self.imageView.image = [UIImage imageNamed:@"home_signin"];
//           }
//               
//               break;
//           case 4://企业走访
//           {
//               self.imageView.image = [UIImage imageNamed:@"home_visit"];
//           }
//               break;
//           case 5://问题处理
//           {
//               self.imageView.image = [UIImage imageNamed:@"home_problemdeal"];
//           }
//               break;
//         case 6://问题上报
//         {
//             self.imageView.image = [UIImage imageNamed:@"home_sendproblem"];
//         }
//             break;
//          
//           default:
//               break;
//       }
}

- (void)setVisitItemModel:(QSItemModel *)visitItemModel{
    _visitItemModel = visitItemModel;
    self.titleLabel.text = visitItemModel.label;
    
    if ([visitItemModel.label isEqualToString:@"新增走访"]) {
        self.imageView.image = [UIImage imageNamed:@"ic_visit_add"];
    }
    if ([visitItemModel.label isEqualToString:@"领导驾驶舱"]) {
        self.imageView.image = [UIImage imageNamed:@"home_leadership"];
    }
    if ([visitItemModel.label isEqualToString:@"一企一档"]) {
        self.imageView.image = [UIImage imageNamed:@"home_enterprise_Archives"];
    }
    if ([visitItemModel.label isEqualToString:@"驻企签到"]) {
        self.imageView.image = [UIImage imageNamed:@"ic_visit_sign"];
    }
    if ([visitItemModel.label isEqualToString:@"企业走访"]) {
        self.imageView.image = [UIImage imageNamed:@"home_visit"];
    }
    if ([visitItemModel.label isEqualToString:@"问题处理"]) {
        self.imageView.image = [UIImage imageNamed:@"ic_visit_dealproblem"];
    }
    if ([visitItemModel.label isEqualToString:@"问题上报"]) {
        self.imageView.image = [UIImage imageNamed:@"ic_visit_sendproblem"];
    }
    //新增
    if ([visitItemModel.label isEqualToString:@"政策宝典"]) {
        self.imageView.image = [UIImage imageNamed:@"home_policy"];
    }
    if ([visitItemModel.label isEqualToString:@"企业运行监测"]) {
        self.imageView.image = [UIImage imageNamed:@"ic_monitoring"];
    }
    
}
@end
